class LoadingUI extends egret.Sprite implements RES.PromiseTaskReporter {

    private readonly stageWidth: number;
    private readonly stageHeight: number;

    public constructor(params) {
        super();

        this.stageWidth = params['stageWidth'];
        this.stageHeight = params['stageHeight'];

        this.createView();
    }

    private textField: egret.TextField;

    private createView(): void {
        const {stageWidth, stageHeight} = this;
        const bgShape = new egret.Shape();
        const textH = 50;
        const bsW = 360;
        const bsH = textH + SizePh * 2;
        const bsX = (stageWidth - bsW) / 2;
        const textFromY = stageHeight / 3;
        const bsY = textFromY - SizePh;
        bgShape.graphics.beginFill(ColorWhite, .3);
        bgShape.graphics.drawRoundRect(bsX, bsY, bsW, bsH, 10, 10);
        bgShape.graphics.endFill();
        this.addChild(bgShape);

        this.textField = new egret.TextField();
        this.textField.y = stageHeight / 3;
        this.textField.width = stageWidth;
        this.textField.height = textH;
        this.textField.textAlign = egret.HorizontalAlign.CENTER;
        this.textField.verticalAlign = egret.VerticalAlign.MIDDLE;
        this.addChild(this.textField);
    }

    public onProgress(current: number, total: number): void {
        this.textField.text = `加载中...${current}/${total}`;
    }
}
